/*
 * @Author: dfh
 * @Date: 2024-10-15 10:13:41
 * @LastEditors: dfh
 * @Modified By: dfh
 * @describe: 
 */
import 'package:flutter_pc_manager/app/modules/order_manager/models/order_manager_model.dart';
import 'package:flutter_pc_manager/app/modules/order_manager/provider/order_manager_provider.dart';
import 'package:get/get.dart';

class OrderManagerController extends GetxController {
  final OrderManagerProvider _provider = OrderManagerProvider();
  final total = 0.obs;
  final orderList = Rx<List<OrderItem>>([]);

  void fetchTableData(int status) async {
    try {
      dynamic result = await _provider.fetchOrderList(1, 0);
      int code = result['code'];
      if (code == 1) {
        OrderVo data = OrderVo.fromJson(result['data']);
        print(data.toJson());
        total.value = data.total;
        orderList.value = data.records;
      } else {
        String msg = result['msg'];
        Get.snackbar('错误', msg);
      }
    } catch (e) {
      dynamic error = e;
      Get.snackbar('错误', error.message ?? '网络异常');
    }
  }
}
